public class Solution {
    //无重复字符最长字串
    public int lengthOfLongestSubstring(String s) {
        int n = s.length();
        int lefft = 0;
        int right = 0;
        int[] arr = new int[128];
        int ret = 0;
        while(right < n) {
            arr[s.charAt(right)]++;
            while(arr[s.charAt(right)] > 1) {
                arr[s.charAt(lefft++)]--;
            }
            ret = Math.max(ret,right - lefft + 1);
            right++;
        }
        return ret;
    }
}
